<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>返利详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">

    <link rel="stylesheet" type="text/css" th:href="@{/js/layui/css/layui.css}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/style.css/}" media="all">
    <link rel="stylesheet" type="text/css" th:href="@{/css/cba/my.css/}" media="all">
</head>
<body class="childrenBody">
<form class="layui-form html_save" lay-filter="form">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">商品来源</label>
            <div class="layui-input-inline">
                <p th:if="${fanli.userType==0}" style="line-height: 40px;color: grey">淘宝</p>
                <p th:if="${fanli.userType==1}" style="line-height: 40px;color: grey">天猫</p>
                <p th:if="${fanli.userType==2}" style="line-height: 40px;color: grey">京东</p>
                <p th:if="${fanli.userType==3}" style="line-height: 40px;color: grey">米选</p>
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">审核状态</label>
            <div class="layui-input-inline">
                <p th:if="${fanli.checkStatus==0}" style="line-height: 40px;color: grey">待审核</p>
                <p th:if="${fanli.checkStatus==1}" style="line-height: 40px;color: grey">通过</p>
                <p th:if="${fanli.checkStatus==2}" style="line-height: 40px;color: grey">拒绝</p>
            </div>
        </div>
    </div>
    <div class="layui-form-item" th:if="${fanli.checkStatus==2}">
        <label class="layui-form-label">拒绝原因</label>
        <div class="layui-input-block">
            <p style="line-height: 40px;color: grey" th:text="${fanli.giveRefuseReason}"></p>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">商品标题</label>
        <div class="layui-input-block">
            <p style="line-height: 40px;color: grey" th:text="${fanli.title}"></p>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">商品主图</label>
        <div class="layui-input-block">
            <img th:src="${fanli.pictUrl}" onclick="previewImg(this)"
                 style="width: 100px;height: 80px;margin-right: 5px;"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品附图</label>
        <div class="layui-input-block">
            <img th:each="c:${fanli.smallImagesList}" th:src="${c}" onclick="previewImg(this)"
                 style="width: 100px;height: 80px;margin-right: 5px;"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">推广链接地址</label>
        <div class="layui-input-block">
            <a th:href="${fanli.url}" style="line-height: 40px;color: grey" th:text="${fanli.url}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">领取优惠券地址</label>
        <div class="layui-input-block">
            <a th:href="${fanli.couponShareUrl}" style="line-height: 40px;color: grey"
               th:text="${fanli.couponShareUrl}"/>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">当前价格</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey" th:text="${fanli.zkFinalPrice}"></p>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">优惠券价格</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey" th:text="${fanli.couponAmount}"></p>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">返佣比例</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey" th:text="${fanli.commissionRate}"></p>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">返利金额</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey" th:text="${fanli.realMoney}"></p>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">领取返利时间</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey"
                   th:text="${#dates.format(fanli.ctime,'yyyy-MM-dd HH:mm:ss')}"></p>
            </div>

        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">提交审核时间</label>
            <div class="layui-input-inline">
                <p style="line-height: 40px;color: grey"
                   th:text="${fanli.applyTime}"></p>
            </div>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">图片凭证</label>
        <div class="layui-input-block">
            <img th:each="c:${fanli.imgsList}" th:src="${c}" onclick="previewImg(this)"
                 style="width: 100px;height: 80px;margin-right: 5px;"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
            <p style="line-height: 40px;color: grey" th:text="${fanli.memo}"></p>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-inline" th:if="${fanli.checkStatus==0}">
            <button class="layui-btn" type="button" id="check">审核</button>
        </div>
    </div>
</form>
<script th:src="@{/js/layui/layui.js}"></script>
<script th:src="@{/js/cba/login-timeout.js}"></script>
<!--<script type="text/javascript" src="js/newsadd.js"></script>-->

<script type="text/javascript" th:inline="javascript">
    layui.use(['table', 'form', "layer"], function () {

        // 操作对象
        var form = layui.form
            , table = layui.table
            , layer = layui.layer
            , $ = layui.jquery;

        //监听提交
        $('#check').click(function () {

            layer.confirm("请选择审核状态", {
                icon: 3,
                btn: ['通过', '拒绝'],
                title: '提示'
            }, function (index) {
                $.ajax({
                    type: "post",
                    url: [[${basePath}]] + "/fanli/apply/check",
                    data: {id: [[${fanli.giveId}]], status: 1},
                    success: function (res) {
                        if (res.success) {
                            layer.msg("操作完成", {icon: 1});
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.location.href = [[${basePath}]] + "/fanli/apply/index";
                                parent.layer.close(index);

                            }, 1000);
                            layer.close(index);


                        }
                    }
                });


            }, function (index) {
                layer.prompt({title: '请输入拒绝理由', formType: 2}, function (pass, index) {
                    $.ajax({
                        type: "post",
                        url: [[${basePath}]] + "/fanli/apply/check",
                        data: {id: [[${fanli.giveId}]], status: 2, reason: pass},
                        success: function (res) {
                            if (res.success) {
                                layer.msg("操作完成", {icon: 1});
                                setTimeout(function () {
                                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    parent.location.href = [[${basePath}]] + "/fanli/apply/index";
                                    parent.layer.close(index);
                                }, 1000);
                                layer.close(index);

                            }
                        }
                    });

                });

            });

        });

        $('#delete').click(function () {
            layer.confirm("确定要删除吗", {
                icon: 3,
                btn: ['删除', '取消'],
                title: '提示'
            }, function (index) {
                $.ajax({
                    type: "post",
                    url: [[${basePath}]] + "/fanli/apply/delete",
                    data: {id: [[${fanli.giveId}]]},
                    success: function (res) {
                        if (res.success) {
                            layer.msg("已删除", {icon: 1});
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index);
                                parent.location.href = [[${basePath}]] + "/fanli/apply/index";
                            }, 1500);
                            layer.close(index);
                        }
                    }
                });
            });
        });

    });

    function previewImg2(obj) {
        var img = new Image();
        img.src = obj.src;
        //var height = img.height + 50; // 原图片大小
        //var width = img.width; //原图片大小
        var imgHtml = "<img src='" + obj.src + "' width='500px' height='500px'/>";
        //弹出层
        layer.open({
            type: 1,
            shade: 0.8,
            offset: 'auto',
            area: [600 + 'px', 650 + 'px'],  // area: [width + 'px',height+'px']  //原图显示
            shadeClose: true,
            scrollbar: false,
            title: "图片预览", //不显示标题
            content: imgHtml, //捕获的积分素，注意：最好该指定的积分素要存放在body最外层，否则可能被其它的相对积分素所影响
            cancel: function () {
                //layer.msg('捕获就是从页面已经存在的积分素上，包裹layer的结构', { time: 5000, icon: 6 });
            }
        });
    }

    //另外打开一个页面显示图片
    function previewImg(obj) {
        if (obj.src.indexOf("aliyuncs.com") != -1) {
            this.previewImg2(obj)
        } else {
            window.open(obj.src);
        }
    }

</script>
</body>
</html>